
import 'package:yp/config/config.dart';

import '../entity/entity_factory.dart';

class HttpResponseListEntity<T> {
  String resultCode;
  String message;
  List<T> data;

  HttpResponseListEntity({this.data, this.message, this.resultCode});

  HttpResponseListEntity.fromJson(Map<String, dynamic> json) {
    /// 状态码
    resultCode = json[Config.API_CODE_FIELD_NAME].toString();
    message = json[Config.API_MESSAGE_FIELD_NAME].toString();
    if (json['results'] != null) {
      data = (json['results'] as List)
          .map((i) => EntityFactory.generateObject<T>(i))
          .toList();
    }
  }

  @override
  String toString() {
    return 'HttpResponseListEntity{resultCode: $resultCode, message: $message, data: $data}';
  }
}
